﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Sinacor.Infra.UI.Common;

namespace Sinacor.Infra.UI.Controls.SmartClient
{
    public static class UIElementExtensionMethods
    {
        /// <summary>
        /// Recuperar a parent window do elemento
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static SinacorWindow GetParentWindow(this UIElement element)
        {
            DependencyObject parent;

            parent = LogicalTreeHelper.GetParent(element);
            if (parent == null)
                return null;
            else if (parent is SinacorWindow)
                return parent as SinacorWindow;
            else
                return GetParentWindow((UIElement)parent);
        }
    }
}
